﻿<%@ Page Title="Reservations Of Trip" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ViewReservationsOfTrip.aspx.cs" Inherits="TravelAgency.AspNet.Agents.ViewReservationsOfTrip" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register assembly="Telerik.OpenAccess.Web" namespace="Telerik.OpenAccess" tagprefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI"
                Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>

    
    <asp:Panel ID="PanelReservations" runat="server">

         <div class="top-padding">
            <h2>Reservation For Trip <asp:Label ID="LabelTripTitle" runat="server"></asp:Label></h2>   
            <asp:Label ID="LabelSearch" runat="server" CssClass="search">
                                            
                <asp:LinkButton ID="LinkButtonSearch" runat="server" CssClass="button-search" Text="Search" 
                    onclick="LinkButtonSearch_Click"></asp:LinkButton>
                &nbsp;
                <asp:TextBox ID="TextBoxSearch" runat="server" Width="120px" Height="18px"></asp:TextBox>                                                            
            </asp:Label>
        </div>

        <telerik:RadListView ID="RadListViewReservations" runat="server" 
            DataSourceID="OpenAccessDataSourceReservations"
            ItemPlaceholderID="PlaceHolder1" AllowPaging="True" 
            DataKeyNames="ReservationId,PeopleCount">
            <LayoutTemplate>
                <div class="reservations">
                    <asp:Panel ID="TripPanel" runat="server">

                            <div class="divider"></div>
                            <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

                        <div class="pager">
                            <telerik:RadDataPager ID="RadDataPager1" runat="server"
                                PageSize="10" Font-Italic="True" BackColor="#FFE9C9" BorderColor="#FFE9C9" BorderStyle="None">
                                <Fields>
                                    <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                    <telerik:RadDataPagerGoToPageField CurrentPageText="Page" />
                                </Fields>
                            </telerik:RadDataPager>
                        </div>
                               
                    </asp:Panel>
                </div>
            </LayoutTemplate>

            <ItemTemplate>
                <div class="reservation">
                    <b>User name:</b> 
                    <asp:Label runat="server" Text='<%# UserNameWordWrapEval("Aspnet_Membership.Aspnet_User.UserName") %>'></asp:Label
                    >; <b>people count:</b>
                    <asp:Label runat="server" Text='<%# Eval("PeopleCount") %>'></asp:Label>
                    <asp:Label runat="server" Text=" "></asp:Label>
                    <asp:LinkButton runat="server" Text="Delete" CommandName="Select"></asp:LinkButton>
                </div>
            </ItemTemplate>

            <SelectedItemTemplate>
                <div class="reservation-selected">
                    <b>User name: </b>
                    <asp:Label runat="server" Text='<%# UserNameWordWrapEval("Aspnet_Membership.Aspnet_User.UserName") %>'></asp:Label
                    >; <b>people count:</b>
                    <asp:Label runat="server" Text='<%# Eval("PeopleCount") %>'></asp:Label>
                    &nbsp;&nbsp;&nbsp;
                    <asp:Label runat="server" CssClass="prompt">Are you sure you want to delete?</asp:Label>
                    <asp:LinkButton runat="server" ID="LinkButtonYas" Text="Yes" OnClick="LinkButtonYas_Click"></asp:LinkButton> /
                    <asp:LinkButton runat="server" ID="LinkButtonNo" Text="No" CommandName="Deselect"></asp:LinkButton>
                </div>
            </SelectedItemTemplate>

            <EmptyDataTemplate>
                <asp:Panel ID="PanelTrip" runat="server" CssClass="navigation-header">                     
                    <asp:Panel runat="server" ID="PanelTripDetails">

                        <h2>No reservations</h2>

                    </asp:Panel>        
                </asp:Panel>                    
            </EmptyDataTemplate>

        </telerik:RadListView>        
    </asp:Panel>
    <br />
    <telerik:OpenAccessDataSource ID="OpenAccessDataSourceReservations" 
        runat="server" 
        ObjectContextProvider="TravelAgency.DAL.TravelAgencyEntities, TravelAgency.DAL" 
        TypeName="TravelAgency.DAL.Reservation" Where="TripId=@tripId" 
        oncontextcreating="OpenAccessDataSourceReservations_ContextCreating">
        <WhereParameters>
            <asp:SessionParameter DbType="Int32" Name="tripId" SessionField="tripId" />
        </WhereParameters>        
    </telerik:OpenAccessDataSource>

    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="TripPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelReservations" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="LinkButtonSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl  ControlID="PanelReservations" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Black">
    </telerik:RadAjaxLoadingPanel>

</asp:Content>
